
package com.fast.fastenjoy.fileplug.domain;

import java.io.File;

import org.apache.commons.lang.StringUtils;

import com.fast.fastenjoy.fileplug.exception.FileMd5HexException;
import com.fast.fastenjoy.fileplug.utils.FilePlugUtils;

public class FileMd5Hex {

	private String path;
	
	private String md5;
	
	private int size;
	
	private File file;

	public FileMd5Hex(){}
	
	public FileMd5Hex(File file) throws FileMd5HexException{
		
		if(file == null || !file.exists() || !file.isFile()){
			throw new FileMd5HexException(file.getAbsolutePath() + "is empty or not is File!");
		}

		this.path = file.getAbsolutePath();
		this.file = file;
		
		FilePlugUtils.getFileMd5AndSize(this);
		
		if(StringUtils.isEmpty(this.md5)){
			throw new FileMd5HexException(file.getAbsolutePath() + " getFileMd5 fail!");
		}
	}
	
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getMd5() {
		return md5;
	}

	public void setMd5(String md5) {
		this.md5 = md5;
	}

	public File getFile() {
		return file;
	}

	public void setFile(File file) {
		this.file = file;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}
	
}
